package okhttp;

import okhttp3.*;

import java.io.IOException;

public class Main {

    private static OkHttpClient okHttpClient = new OkHttpClient();

    public static void run() {
        Request request = new Request.Builder()
                .url("http://publicobject.com/helloworld.txt")
                .build();

        okHttpClient.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
                e.printStackTrace();
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                System.out.println(response.body().string());
            }
        });
    }

    public static void main(String[] args) {
        Main.run();
    }
}
